/*
 * Copyright (C) 2010 Graham Allan
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.strath.cis.grallan.findbugs.adaptiveranking.gui;

import edu.strath.cis.grallan.findbugs.adaptiveranking.IBugRankMap;
import edu.umd.cs.findbugs.gui2.BugRenderer;
import edu.umd.cs.findbugs.gui2.BugTreeModel;
import edu.umd.cs.findbugs.gui2.BugTreePopupProvider;
import edu.umd.cs.findbugs.gui2.IApplicationState;
import edu.umd.cs.findbugs.gui2.sort.SortableBugTree;

/**
 * @author Graham Allan (grallan@cis.strath.ac.uk)
 */
public class RankedBugTree extends SortableBugTree {

	private final IBugRankMap bugRankMap;

	/**
	 * Creates a new RankedBugTree. Use this constructor when you have a bug BugTreeModel.
	 * Otherwise, use
	 * {@link RankedBugTree#RankedBugTree(IApplicationState, BugTreePopupProvider, IBugRankMap)}
	 * which is the equivalent of calling this method with bugTreeModel = null.
	 */
	public RankedBugTree(BugTreeModel model, IApplicationState appState, BugTreePopupProvider popupProvider,
			IBugRankMap bugRankMap) {
		super(model, appState, popupProvider);
		this.bugRankMap = bugRankMap;

		initialise();
	}

	public RankedBugTree(IApplicationState appState, BugTreePopupProvider popupProvider, IBugRankMap bugRankMap) {
		this(null, appState, popupProvider, bugRankMap);
	}

	@Override
	protected BugRenderer bugCellRenderer() {
		return new RankedBugRenderer(bugRankMap);
	}

	@Override
	protected boolean superShouldInitialiseSettings() {
		return false;
	}

	@Override
	public RankedBugTree cloneWithNewModel(BugTreeModel newModel) {
		return new RankedBugTree(newModel, appState, popupProvider, bugRankMap);
	}

}
